Ubuntu永久换源

您所在的位置:网站首页 ubuntu pip 换源 Ubuntu永久换源

Ubuntu永久换源

2023-08-23 06:16| 来源: 网络整理| 查看: 265

在ubuntu系统中,安装软件或者在虚拟环境中安装一些库往往下载速度慢,需要等待较长的时间,以下是临时修改以及永久修改国内源的方法:

一.临时修改国内源

临时修改源方法: 可以在使用pip的时候在后面加上-i参数,指定pip源

pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple 二.永久修改国内源 1. 创建pip.conf文件 cd ~/.pip

如果提示目录不存在的话,我们要自行创建一个,再进入目录:

mkdir ~/.pip cd ~/.pip

在.pip文件夹下创建一个名为pip.conf文件:

touch pip.conf 2. 编辑pip.conf文件 sudo gedit ~/.pip/pip.conf

打编辑名为pip.conf文件,将下面豆瓣源的内容复制到文件中:

[global] index-url = http://pypi.douban.com/simple [install] trusted-host=pypi.douban.com 3. Windows永久更换国内源

(1) Window + R调出windows文件管理器中,输入 %APPDATA%

(2) 会定位到一个新的目录下,在该目录下新建pip文件夹,然后到pip文件夹里面去新建一个pip.ini文件

(3) 在新建的pip.ini文件中输入以下内容,文件路径:

“C:\Users\Administrator\AppData\Roaming\pip\pip.ini”

[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple [install] trusted-host=pypi.tuna.tsinghua.edu.cn 4. 更换其他国内源

列举pip国内的一些镜像:

1.阿里云 https://mirrors.aliyun.com/pypi/simple/   2.中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/   3.豆瓣 https://pypi.douban.com/simple/   4.清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/   5.中国科学技术大学 https://pypi.mirrors.ustc.edu.cn/simple/



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3